$(function() {
	$(".next-bt").click(function() {
		if (boxWidth >= totalLength) {
			$(this).attr('disabled', false);
		} else {
			var offset = $('.model-column-inner li img').eq(pictureIndex).width();
			pictureWidth += offset;
			$(".model-column-inner").animate({
				"left" : -pictureWidth
			});
			$(".model-btr-inner").animate({
				"left" : -(pictureWidth + 1080)
			});
			$(".model-btl-inner").animate({
				"left" : -(pictureWidth - 54)
			});
			totalLength -= (offset + 31);
			pictureIndex++;
		}
	});
	
	$(".pre-bt").click(function() {
		if (pictureIndex == 0) {
			$(this).attr('disabled', false);
		} else {
			pictureIndex--;
			var offset = $('.model-column-inner li img').eq(pictureIndex).width();
			pictureWidth -= offset;
			$(".model-column-inner").animate({
				"left" : -pictureWidth
			});
			$(".model-btl-inner").animate({
				"left" : -(pictureWidth - 54)
			});
			$(".model-btr-inner").animate({
				"left" : -(pictureWidth + 1080)
			});
			totalLength += (offset + 31);
		}
	});
	$(".mask,.life-big-r").click(function() {
		$(".mask").hide();
		$(".model-big").hide();
	});
	$(".model-column-inner img").click(function() {
		var index = $(this).parent('li').index();
		var src_img = $(this).attr("src");
		var width = $(this).attr('originalWidth');
        var height = $(this).attr('originalHeight');
		var desc = $(this).siblings('input:hidden').val();
		tmpHeight = 600 * (height / width);
		if (tmpHeight > 500) {
			width = 500 * (width / height);
			height = 500;
		} else {
			width = 600;
			height = tmpHeight;
		}

		$('#description').html(desc);
		var windowHeight = $(window).height();
		var paddingTop = (windowHeight - height) / 2;
		if (paddingTop > 100) {
			paddingTop = 100;
		}
		if (paddingTop < 0) {
			paddingTop = 0;
		}
		$('.model-big-inner').parent('.fl').css({'padding-top' : parseInt(paddingTop)});
		$('.model-big-inner img').attr("width", parseInt(width));
		$('.model-big-inner img').attr("height", parseInt(height));
		var marginLeft = 0 - (width / 2);
		$('.life-big').css('margin-left', marginLeft);
		var maskHeight = $('body').height();
		$(".mask").css('height', maskHeight);
		$(".mask").show();
		$(".model-big img").attr("src", src_img).parents(".model-big").fadeIn('slow');
	});

	$('.model-big').click(function() {
		$(".mask").hide();
		$(".model-big").hide();
	});
});